package com.tecklab.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tecklab.demo.entity.UserEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Optional;

/**
 * 增：add create insert
 * 删：delete remove
 * 改：update modify
 * 查：seletXXX getXX findXX
 */
@Mapper
public interface UserMapper extends BaseMapper<UserEntity> {

    @Select("SELECT * FROM user")
    List<UserEntity> selectAll();

    @Select("SELECT * FROM user WHERE username = #{username} AND password = #{password}")
    UserEntity findByUsernameAndPassword(@Param("username") String username, @Param("password") String password);


    @Select("SELECT COUNT(*) > 0 FROM user WHERE username = #{username}")
    boolean existsByUsername(@Param("username") String username);
}